using UnityEngine;
using UnityEngine.UI;

//Encoding：UTF-8
public class Pai : MonoBehaviour
{
    public Pai2dScriptableObject pai2dConfig;
    public MintAnimationsPlay selectedAnim;
    public GameObject effect;
    public Image image;
    public int paiID;

    public static Pai selectedPai;

    public void SetPaiType(int paiID)
    {
        this.paiID = paiID;
        image.sprite = pai2dConfig.pai2dTexture[paiID];
    }

    public void SetEffectTip(bool isShow)
    {
        effect.SetActive(isShow);
    }

    public void Click()
    {
        bool isSelectThis = selectedPai == this;
        selectedAnim?.MintPlay(isSelectThis);
        if (!isSelectThis)
        {
            selectedPai?.selectedAnim?.MintPlay(true);
        }
        selectedPai = isSelectThis ? null : this;
    }

    private void OnDestroy()
    {
        if (selectedPai == this)
        {
            selectedPai = null;
        }
    }
}
